﻿using System.Collections.Generic;
using System.Data;
using System.Linq;

namespace Kernel
{
    public class Graph
    {
        public List<GraphNode> Nodes { get; private set; }

        public  Graph()
        {
            Nodes = new List<GraphNode>();
        }

        public GraphNode GetNodeByName(string name)
        {
            return Nodes.FirstOrDefault(n => n.Name == name);
        }

        public void AddNode(GraphNode newNode)
        {
            if(GetNodeByName(newNode.Name) != null)
                throw new DuplicateNameException();
            Nodes.Add(newNode);
        }

        public void AddNodes(List<GraphNode> newNodes)
        {
            newNodes.ForEach(AddNode);
        }
    }
}
